package main

import "fmt"

func main() {
	// 定义一个4行4列的数组，逐个从键盘输出，将第1行和第4行的数据进行交换，将第2行和第3行的数据进行交换
	var twoDimensionArr [4][4]int
	var num int
	for i := 0; i < 4; i++ {
		for j := 0; j < 4; j++ {
			fmt.Printf("请输入第%d行，第%d列的数字：", i+1, j+1)
			fmt.Scanln(&num)
			twoDimensionArr[i][j] = num
		}
		fmt.Println(twoDimensionArr[i])
	}
	//var twoDimensionArr = [4][4]int{{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}, {13, 14, 15, 16}}
	var temp0 [4]int
	var temp1 [4]int
	var temp2 [4]int
	var temp3 [4]int
	for i := 0; i < len(twoDimensionArr); i++ {
		if i == 0 {
			temp0 = twoDimensionArr[i]
		}
		if i == 1 {
			temp1 = twoDimensionArr[i]
		}
		if i == 2 {
			temp2 = twoDimensionArr[i]
			//temp1, twoDimensionArr[i] = twoDimensionArr[i], temp1
		}
		if i == 3 {
			temp3 = twoDimensionArr[i]
			//temp0, twoDimensionArr[i] = twoDimensionArr[i], temp0
		}
		fmt.Println(twoDimensionArr[i])
	}
	fmt.Println("-------")
	// 交换位置
	for i := 0; i < len(twoDimensionArr); i++ {
		if i == 0 {
			temp3, twoDimensionArr[i] = twoDimensionArr[i], temp3
		}
		if i == 1 {
			temp2, twoDimensionArr[i] = twoDimensionArr[i], temp2
		}
		if i == 2 {
			temp1, twoDimensionArr[i] = twoDimensionArr[i], temp1
		}
		if i == 3 {
			temp0, twoDimensionArr[i] = twoDimensionArr[i], temp0
		}
		fmt.Println(twoDimensionArr[i])
	}
}
